<?php
class MaYi{
	var $sock;
        var $domain;
	function __construct($port = 4080, $dm ="o" ){
                $this->domain = $dm;
		$this->sock = pfsockopen("localhost", $port, $errno, $errstr);
		if (!$this->sock) 
			syslog("ERROR: $errno - $errstr");
	} 

	function __destruct() {
	} 

	function domethod(){

		$input = "1024000";
		$input = pack("I", strlen($input)).$input;
	
        	$input = "P".pack("I", 1)."\001".$input;
                $rlen = strlen($input);
                $einput = pack("I", strlen($input)).$input;
                fwrite($this->sock, $einput);
     	        $readlen = $READ = 102400;

		$response = fread($this->sock, $READ);
		while (!feof($this->sock) )
		{
			$contstr = fread ( $this->sock,  $READ );
			if ( $contstr )
				$response .= $contstr;
			else
				break;
		}
                echo strlen($response);
	}
}

list($start_usec, $start_sec) = explode(" ", microtime());
$start_time = ((float) $start_usec + (float) $start_sec);


 $obj = new MaYi(7080, "o");
 $obj->domethod();

list($end_usec, $end_sec) = explode(" ", microtime());
$end_time = ((float) $end_usec + (float) $end_sec);
$total_time = 1000*($end_time - $start_time);
echo "<BR>总计耗时：".$total_time."毫秒 <BR>";

?>
